home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 January: Mac OS SDK / Dev.CD Jan 97 SDK2.toast / Development Kits (Disc 2) / OpenDoc / OpenDoc Development / Debugging Support / OpenDoc™ Source Code / Binding / ODBindng.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1996-08-28  |  18.4 KB  |  747 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        ODBindng.cpp
  3.  
  4.     Contains:    SOM Implementation for Binding class.
  5.  
  6.     Owned by:    Caia Grisar
  7.  
  8.     Copyright:    © 1993 - 1996 by Apple Computer, Inc., all rights reserved.
  9.  
  10.     Change History (most recent first):
  11.  
  12.          <5>     6/27/96    RA        Don't dereference null structs
  13.          <4>     6/24/96    RA        T10025: Made new Binding API CORBA
  14.                                     compliant. Added ODGetFileFromEditor
  15.                                     method.
  16.          <3>     6/21/96    RA        T10025: Added new Binding API
  17.         <13>     10/8/95    TJ        Fixes Recomended by Refball
  18.         <12>      8/3/95    RR        #1257260: Collapse B classes. Remove
  19.                                     somInit methods. Don't call IsInitialized
  20.                                     or SubclassResponsibility
  21.         <11>     7/24/95    CG        1270320: Memory leak fixes.
  22.         <10>     5/18/95    CG        #1241621 BB: Need to implement Purge for
  23.                                     Binding subsystem objects.
  24.          <9>     5/17/95    VL        1170098: Added private-by-convention
  25.                                     ConstructNoPart.
  26.          <8>      5/1/95    CG        #1241628    BB: SOM_TRY blocks needed in
  27.                                     Binding SOM methods. #1243669    XMP in
  28.                                     ODBindng.cpp ifdef
  29.          <7>     4/26/95    CG        last check in comment should have been :
  30.                                     1241628    SOM_TRY blocks needed in Binding
  31.                                     SOM methods.
  32.          <6>     4/26/95    CG        1211082 BB: 5$ Bugs need to be evaluated
  33.                                     and removed from Core
  34.          <5>    12/13/94    CG        #1206024: Added function prefix to .idl
  35.                                     file.
  36.          <4>     8/24/94    CG        #1181622: Updated file ownership.
  37.          <3>     8/17/94    CG        #1181519: The Binding helper object was not
  38.                                     getting initialized  in InitBinding.
  39.          <2>      7/1/94    CG        Check for somSelf->IsInitialized in
  40.                                     InitBinding.
  41.          <1>     6/20/94    CG        first checked in
  42.     To Do:
  43. */
  44.  
  45. #define ODBinding_Class_Source
  46. #define VARIABLE_MACROS
  47. #include <ODBindng.xih>
  48.  
  49. #ifndef _BINDNGH_
  50. #include "BindngH.h"
  51. #endif
  52.  
  53. #ifndef SOM_ODSession_xh
  54. #include <ODSessn.xh>
  55. #endif
  56.  
  57. #ifndef SOM_Module_Apple_defined
  58. #include <NoPart.xh>
  59. #endif
  60.  
  61. #ifndef SOM_ODNameSpaceManager_xh
  62. #include <NmSpcMg.xh>
  63. #endif
  64.  
  65. #ifndef SOM_ODObjectNameSpace_xh
  66. #include <ObjectNS.xh>
  67. #endif
  68.  
  69. #ifndef SOM_ODObjectIterator_xh
  70. #include <ObjctItr.xh>
  71. #endif
  72.  
  73. #ifndef SOM_ODTypeList_xh
  74. #include <TypeList.xh>
  75. #endif
  76.  
  77. #ifndef SOM_ODTypeListIterator_xh
  78. #include <TypLsItr.xh>
  79. #endif
  80.  
  81. #ifndef SOM_ODStorageSystem_xh
  82. #include <ODStor.xh>
  83. #endif
  84.  
  85. #ifndef SOM_ODValueNameSpace_xh
  86. #include <ValueNS.xh>
  87. #endif
  88.  
  89. #ifndef _ISOSTR_
  90. #include "ISOStr.h"
  91. #endif
  92.  
  93. #ifndef _NMSPCUTL_
  94. #include "NmSpcUtl.h"
  95. #endif
  96.  
  97. #ifndef _BARRAY_
  98. #include "BArray.h"
  99. #endif
  100.  
  101.  
  102. SOM_Scope ODBoolean  SOMLINK ODBindingGetODFileSpecFromEditor(ODBinding *somSelf, Environment *ev,
  103.         ODEditor editor,
  104.         ODByteArray* fileSpec)
  105. {
  106.     ODBindingData *somThis = ODBindingGetData(somSelf);
  107.     ODBindingMethodDebug("ODBinding","ODBindingGetFileFromEditor");
  108.     
  109.     ODBoolean result = kODFalse;
  110.     
  111.     SOM_TRY
  112.     
  113.     Environment* ev = somGetGlobalEnvironment();
  114.  
  115.     ODValueNameSpace* fileFromEditorNS = 
  116.         (ODValueNameSpace*)_fNmSpcMgr->HasNameSpace( ev, "FileFromEditor" );
  117.  
  118.     if ( fileFromEditorNS )
  119.     {
  120.         ODFileSpec* fsspecPtr = kODNULL;
  121.         ODULong     valueLength;
  122.         
  123.         result = ValueNameSpaceGetEntry( fileFromEditorNS, 
  124.                             ev,  editor, (ODPtr*) &fsspecPtr,  &valueLength);
  125.         if (result)
  126.         {            
  127.              UseByteArray(fileSpec, fsspecPtr, sizeof(ODFileSpec)); // place contents of FSSpec into byteArray
  128.         }
  129.         else
  130.             fileSpec->_buffer = kODNULL;
  131.     }
  132.     
  133.     SOM_CATCH_ALL
  134.     SOM_ENDTRY
  135.     
  136.     return result;
  137.     
  138. }
  139.  
  140. SOM_Scope void  SOMLINK ODBindingInitBinding(ODBinding *somSelf, Environment *ev,
  141.         ODSession* session)
  142. {
  143.     ODBindingData *somThis = ODBindingGetData(somSelf);
  144.     ODBindingMethodDebug("ODBinding","InitBinding");
  145.  
  146.     SOM_TRY
  147.     
  148.     somSelf->InitObject(ev);
  149.         
  150.     _fSession = session;
  151.     _fNmSpcMgr = session->GetNameSpaceManager(ev);
  152.     _fBinding = new Binding();
  153.     _fBinding->InitBinding(_fSession);
  154.     
  155.     SOM_CATCH_ALL
  156.     SOM_ENDTRY
  157. }
  158.  
  159. SOM_Scope ODPart*  SOMLINK ODBindingConstructNoPart(ODBinding *somSelf, Environment *ev)
  160. {
  161.     ODBindingData *somThis = ODBindingGetData(somSelf);
  162.     ODBindingMethodDebug("ODBinding","ConstructNoPart");
  163.  
  164.     ODPart*    noPart;
  165.     
  166.     SOM_TRY
  167.     
  168.     noPart = new Apple_NoPart;
  169.     
  170.     SOM_CATCH_ALL
  171.         noPart = kODNULL;
  172.     SOM_ENDTRY
  173.     return noPart;
  174. }
  175.  
  176. SOM_Scope ODEditor  SOMLINK ODBindingChooseEditorForPart(ODBinding *somSelf, Environment *ev,
  177.         ODStorageUnit* thePartSU,
  178.         ODType newKind)
  179. {
  180.     ODBindingData *somThis = ODBindingGetData(somSelf);
  181.     ODBindingMethodDebug("ODBinding","ChooseEditorForPart");
  182.  
  183.      ODEditor returnVal = kODNULL;
  184.  
  185.     SOM_TRY
  186.  
  187.     returnVal = _fBinding->ChooseEditorForPart(thePartSU, newKind);
  188.  
  189.     SOM_CATCH_ALL
  190.     SOM_ENDTRY
  191.  
  192.     return (returnVal);
  193. }
  194.  
  195. SOM_Scope ODContainerSuite  SOMLINK ODBindingGetContainerSuite(ODBinding *somSelf, Environment *ev,
  196.         ODContainerType containerType)
  197. {
  198.     ODBindingData *somThis = ODBindingGetData(somSelf);
  199.     ODBindingMethodDebug("ODBinding","GetContainerSuite");
  200.  
  201.     ODContainerSuite returnVal = kODNULL;
  202.  
  203.     SOM_TRY
  204.  
  205.     returnVal = _fBinding->GetContainerSuite( containerType );
  206.  
  207.     SOM_CATCH_ALL
  208.     SOM_ENDTRY
  209.  
  210.     return (returnVal);
  211. }
  212.  
  213. SOM_Scope ODTypeList*  SOMLINK ODBindingGetAllCategoriesForKind(ODBinding *somSelf, Environment *ev,
  214.         ODKind kind)
  215. {
  216.     ODBindingData *somThis = ODBindingGetData(somSelf);
  217.     ODBindingMethodDebug("ODBinding","ODBindingGetAllCategoriesForKind");
  218.  
  219.     ODTypeList*    categoryList = kODNULL;
  220.     
  221.     SOM_TRY
  222.         // look it up in the kindcategory namespace
  223.     ODObjectNameSpace* kindCategoryNameSpace = 
  224.         (ODObjectNameSpace*)_fNmSpcMgr->HasNameSpace( ev, kODKind );
  225.     
  226.     if (kindCategoryNameSpace)
  227.     {
  228.         if (kindCategoryNameSpace->GetEntry(ev, (ODISOStr)kind, 
  229.                                         (ODObject**)&categoryList ))
  230.             return categoryList;
  231.         else
  232.             return kODNULL;
  233.     }
  234.     
  235.     SOM_CATCH_ALL
  236.     SOM_ENDTRY
  237.     
  238.     return categoryList;
  239. }
  240.  
  241.  
  242. SOM_Scope ODBoolean  SOMLINK ODBindingGetAllEditorsForKind(ODBinding *somSelf, Environment *ev,
  243.         ODKind kind,
  244.         ODTypeList* editorList)
  245. {
  246.     ODBindingData *somThis = ODBindingGetData(somSelf);
  247.     ODBindingMethodDebug("ODBinding","ODBindingGetAllEditorsForKind");
  248.  
  249.     ODTypeList*            kindsList     = kODNULL;
  250.     ODEditor             editor         = kODNULL; ODVolatile(editor);
  251.     ODObjectIterator*     iter         = kODNULL; ODVolatile(iter);
  252.     ODULong                len         = 0;
  253.     ODBoolean            retval         = kODFalse;
  254.  
  255.     SOM_TRY
  256.     
  257.     if (editorList)
  258.     {
  259.             // get the editorkinds namespace
  260.         ODObjectNameSpace* editorkindsNameSpace = 
  261.             (ODObjectNameSpace*)_fNmSpcMgr->HasNameSpace( ev, kODEditorKinds );
  262.         
  263.         if (editorkindsNameSpace)
  264.         {
  265.                 //    iterate through editorKinds namespace
  266.             iter = editorkindsNameSpace->CreateIterator(ev) ;
  267.             for (iter->First(ev, (ODISOStr*)&editor, (ODObject**)&kindsList, &len);
  268.                     iter->IsNotComplete(ev);
  269.                     iter->Next(ev, (ODISOStr*)&editor, (ODObject**)&kindsList, &len))
  270.             {
  271.                 if ( kindsList )
  272.                 {
  273.                     if ( kindsList->Contains(ev, kind) )
  274.                     {
  275.                         editorList->AddLast(ev, editor);
  276.                         retval = kODTrue;
  277.                     }
  278.                     ODDisposePtr( editor );
  279.                 }
  280.             }
  281.             ODDeleteObject( iter );
  282.         }
  283.     }
  284.     SOM_CATCH_ALL
  285.         ODDeleteObject(iter);
  286.         ODDeleteObject(editor);
  287.     SOM_ENDTRY
  288.     
  289.     return retval;
  290. }
  291.  
  292. SOM_Scope void  SOMLINK ODBindingGetAllKindsForEditor(ODBinding *somSelf, Environment *ev,
  293.         ODEditor editor,
  294.         ODTypeList* kindList)
  295. {
  296.     ODBindingData *somThis = ODBindingGetData(somSelf);
  297.     ODBindingMethodDebug("ODBinding","ODBindingGetAllKindsForEditor");
  298.  
  299.     ODTypeListIterator* iter = kODNULL; ODVolatile(iter);
  300.  
  301.     SOM_TRY
  302.     
  303.     if (kindList)
  304.     {
  305.             // get the editorkinds namespace
  306.         ODObjectNameSpace* editorkindsNameSpace = 
  307.             (ODObjectNameSpace*)_fNmSpcMgr->HasNameSpace( ev, kODEditorKinds );
  308.         
  309.         if (editorkindsNameSpace)
  310.         {
  311.             ODTypeList*    nsKindsList = kODNULL;
  312.             ODType        kind         = kODNULL;
  313.             if(editorkindsNameSpace->GetEntry( ev, (ODType)editor, 
  314.                                                      (ODObject**)&nsKindsList ))
  315.             {
  316.                 iter = nsKindsList->CreateTypeListIterator(ev);
  317.                 for (kind = iter->First(ev);
  318.                         iter->IsNotComplete(ev);
  319.                         kind = iter->Next(ev))
  320.                 {
  321.                     kindList->AddLast(ev, kind);
  322.                     ODDisposePtr(kind);
  323.                 }
  324.                 
  325.                 ODDeleteObject( iter );
  326.             }
  327.         }
  328.     }
  329.     SOM_CATCH_ALL
  330.         ODDeleteObject(iter);
  331.     SOM_ENDTRY
  332. }
  333.  
  334. SOM_Scope ODBoolean  SOMLINK ODBindingGetAllEditorsForCategory(ODBinding *somSelf, Environment *ev,
  335.         ODCategory category,
  336.         ODTypeList* editorList)
  337. {
  338.     ODBindingData *somThis = ODBindingGetData(somSelf);
  339.     ODBindingMethodDebug("ODBinding","ODBindingGetAllEditorsForCategory");
  340.     
  341.     ODBoolean             retval             = kODFalse;
  342.     ODTypeListIterator* esi             = kODNULL; ODVolatile(esi);
  343.     ODObjectIterator*     iter             = kODNULL; ODVolatile(iter);
  344.     ODTypeList*         thisEditorSet     = kODNULL; ODVolatile(thisEditorSet);
  345.     ODULong    len;
  346.     
  347.     SOM_TRY
  348.     
  349.     ODObjectNameSpace* kindCategories = 
  350.         (ODObjectNameSpace*)_fNmSpcMgr->HasNameSpace( ev, kODKind ) ;
  351.     if ( kindCategories )
  352.     {
  353.         ODTypeList*         categoriesList  = kODNULL;
  354.         ODType                 kind;
  355.  
  356.         iter = kindCategories->CreateIterator(ev) ;
  357.         for (iter->First(ev, (ODISOStr*)&kind, (ODObject**)&categoriesList, &len);
  358.                 iter->IsNotComplete(ev);
  359.                 iter->Next(ev, (ODISOStr*)&kind, (ODObject**)&categoriesList, &len))
  360.         {
  361.             if ( categoriesList && categoriesList->Contains( ev, category ) )
  362.             {
  363.                 thisEditorSet = _fSession->GetStorageSystem(ev)->CreateTypeList(ev,kODNULL);
  364.                 
  365.                 if ( somSelf->GetAllEditorsForKind(ev,
  366.                                             kind, thisEditorSet ) )
  367.                 {    
  368.                         esi = thisEditorSet->CreateTypeListIterator(ev);
  369.                         for ( ODEditor editor = esi->First(ev) ; esi->IsNotComplete(ev) ;
  370.                                 editor = esi->Next(ev) )
  371.                         {
  372.                             editorList->AddLast(ev, editor);
  373.                         }
  374.                         ODDeleteObject( esi );
  375.                         
  376.                         retval = kODTrue;
  377.                 }
  378.                 ODDeleteObject( thisEditorSet );
  379.             }
  380.         }
  381.         ODDeleteObject( iter );
  382.     }
  383.     
  384.     SOM_CATCH_ALL
  385.             ODDeleteObject( thisEditorSet );
  386.             ODDeleteObject( iter );
  387.             ODDeleteObject( esi );
  388.     SOM_ENDTRY
  389.     
  390.     return retval ;
  391. }
  392.  
  393. SOM_Scope ODEditor  SOMLINK ODBindingSetSysPrefEditorForKind(ODBinding *somSelf, Environment *ev,
  394.         ODEditor editor,
  395.         ODKind kind)
  396. {
  397.     ODBindingData *somThis = ODBindingGetData(somSelf);
  398.     ODBindingMethodDebug("ODBinding","ODBindingSetSysPrefEditorForKind");
  399.  
  400.     ODEditor setEditor = kODNULL; ODVolatile(setEditor);
  401.     
  402.         // look it up in the editorkinds namespace
  403.     SOM_TRY
  404.     
  405.     ODValueNameSpace* sysPrefEditorKindsNameSpace = 
  406.         (ODValueNameSpace*)_fNmSpcMgr->HasNameSpace( ev, 
  407.                                                         kODSysPrefEditorKinds );
  408.     
  409.     if (sysPrefEditorKindsNameSpace)
  410.     {
  411.         ODULong strLength = ODISOStrLength((const ODISOStr)editor);
  412.         setEditor = (ODEditor)ODNewPtrClear(strLength+1, kDefaultHeapID);
  413.         ODISOStrNCopy((ODISOStr)setEditor,(const ODISOStr)editor, strLength);
  414.         ValueNameSpaceRegister( sysPrefEditorKindsNameSpace, ev, (ODISOStr)kind, 
  415.                                             (ODPtr)setEditor, strLength+1 );
  416.         _fNmSpcMgr->UpdatePreferences(ev);
  417.     }
  418.     
  419.     SOM_CATCH_ALL
  420.         ODDeleteObject(setEditor);
  421.     SOM_ENDTRY
  422.     
  423.     return setEditor;
  424. }
  425.  
  426. SOM_Scope ODEditor  SOMLINK ODBindingSetSysPrefEditorForCategory(ODBinding *somSelf, Environment *ev,
  427.         ODEditor editor,
  428.         ODCategory category)
  429. {
  430.     ODBindingData *somThis = ODBindingGetData(somSelf);
  431.     ODBindingMethodDebug("ODBinding","ODBindingSetSysPrefEditorForCategory");
  432.  
  433.     ODEditor setEditor = kODNULL; ODVolatile(setEditor);
  434.     
  435.     SOM_TRY
  436.     
  437.     // look it up in the editorkinds namespace
  438.     ODValueNameSpace* sysPrefEditorCategoriesNameSpace = 
  439.         (ODValueNameSpace*)_fNmSpcMgr->HasNameSpace( ev, 
  440.                                                    kODSysPrefEditorCategories );
  441.     
  442.     if (sysPrefEditorCategoriesNameSpace)
  443.     {
  444.         ODULong strLength = ODISOStrLength((const ODISOStr)editor);
  445.         setEditor = (ODEditor)ODNewPtrClear(strLength+1, kDefaultHeapID);
  446.         ODISOStrNCopy((ODISOStr)setEditor,(const ODISOStr)editor, strLength);
  447.         ValueNameSpaceRegister( sysPrefEditorCategoriesNameSpace, ev, 
  448.                                 (ODISOStr)category, (ODPtr)setEditor, strLength+1);
  449.         _fNmSpcMgr->UpdatePreferences(ev);
  450.     }
  451.     
  452.     SOM_CATCH_ALL
  453.         ODDeleteObject(setEditor);
  454.     SOM_ENDTRY
  455.     
  456.     return setEditor;
  457. }
  458.  
  459. SOM_Scope ODEditor  SOMLINK ODBindingGetSysPrefEditorForKind(ODBinding *somSelf, Environment *ev,
  460.         ODKind kind)
  461. {
  462.     ODBindingData *somThis = ODBindingGetData(somSelf);
  463.     ODBindingMethodDebug("ODBinding","ODBindingGetSysPrefEditorForKind");
  464.  
  465.      ODEditor     theEditor             = kODNULL;
  466.     
  467.     SOM_TRY
  468.     
  469.         // look it up in the editorkinds namespace
  470.     ODValueNameSpace* sysPrefEditorKindsNameSpace = 
  471.         (ODValueNameSpace*)_fNmSpcMgr->HasNameSpace( ev, 
  472.                                                         kODSysPrefEditorKinds );
  473.     if (sysPrefEditorKindsNameSpace)
  474.     {
  475.         ODULong        valueLen = 0;
  476.         ODBoolean     sysPrefEditorFound = kODFalse;
  477.  
  478.         sysPrefEditorFound = ValueNameSpaceGetEntry( 
  479.                                 sysPrefEditorKindsNameSpace, ev, kind, 
  480.                                 (ODPtr*) &theEditor, &valueLen );
  481.     }
  482.     
  483.     SOM_CATCH_ALL
  484.     SOM_ENDTRY
  485.     
  486.     return theEditor;
  487. }
  488.  
  489. SOM_Scope ODEditor  SOMLINK ODBindingGetSysPrefEditorForCategory(ODBinding *somSelf, Environment *ev,
  490.         ODCategory category)
  491. {
  492.     ODBindingData *somThis = ODBindingGetData(somSelf);
  493.     ODBindingMethodDebug("ODBinding","ODBindingGetSysPrefEditorForCategory");
  494.  
  495.      ODEditor theEditor = kODNULL;
  496.     
  497.     SOM_TRY
  498.     
  499.         // look it up in the editorkinds namespace
  500.     ODValueNameSpace* sysPrefEditorCategoriesNameSpace = 
  501.         (ODValueNameSpace*)_fNmSpcMgr->HasNameSpace( ev, 
  502.                                                    kODSysPrefEditorCategories );
  503.     
  504.     if (sysPrefEditorCategoriesNameSpace)
  505.     {
  506.         ODULong        valueLen = 0;
  507.         ODBoolean     sysPrefEditorFound = kODFalse;
  508.  
  509.         sysPrefEditorFound = ValueNameSpaceGetEntry( 
  510.                                 sysPrefEditorCategoriesNameSpace, ev, category, 
  511.                                 (ODPtr*) &theEditor, &valueLen );
  512.     }
  513.     
  514.     SOM_CATCH_ALL
  515.     SOM_ENDTRY
  516.     
  517.     return theEditor;
  518. }
  519.  
  520.  
  521. SOM_Scope ODBoolean  SOMLINK ODBindingGetUserStringForKind(ODBinding *somSelf, Environment *ev,
  522.         ODKind kind,
  523.         ODName* name)
  524. {
  525.     ODBindingData *somThis = ODBindingGetData(somSelf);
  526.     ODBindingMethodDebug("ODBinding","ODBindingGetUserStringForKind");
  527.     
  528.     ODBoolean    result  = kODFalse ;
  529.     ODName*        userString = kODNULL;
  530.     
  531.     SOM_TRY
  532.     
  533.         // look it up in the spaceName namespace
  534.     ODValueNameSpace* userStringNameSpace = 
  535.         (ODValueNameSpace*)_fNmSpcMgr->HasNameSpace( ev, kODKindUserString );
  536.  
  537.     if (userStringNameSpace)
  538.         result = ValueNameSpaceGetODName(userStringNameSpace, ev, kind, &userString );
  539.         
  540.     if (userString)
  541.         *name = *userString;
  542.     else
  543.         InitIText(name);
  544.     
  545.     SOM_CATCH_ALL
  546.     SOM_ENDTRY
  547.     
  548.     return result ;
  549. }
  550.  
  551. SOM_Scope ODBoolean  SOMLINK ODBindingGetUserStringForEditor(ODBinding *somSelf, Environment *ev,
  552.         ODEditor editor,
  553.         ODName* name)
  554. {
  555.     ODBindingData *somThis = ODBindingGetData(somSelf);
  556.     ODBindingMethodDebug("ODBinding","ODBindingGetUserStringForEditor");
  557.  
  558.     ODBoolean    result  = kODFalse ;
  559.     ODName*        userString = kODNULL;
  560.  
  561.     SOM_TRY
  562.     
  563.         // look it up in the spaceName namespace
  564.     ODValueNameSpace* userStringNameSpace = 
  565.         (ODValueNameSpace*)_fNmSpcMgr->HasNameSpace( ev, kODEditorUserString );
  566.  
  567.     if (userStringNameSpace)
  568.         result = ValueNameSpaceGetODName(userStringNameSpace, ev, editor, &userString );
  569.     
  570.     if (userString)
  571.         *name = *userString;
  572.     else
  573.         InitIText(name);
  574.     
  575.     SOM_CATCH_ALL
  576.     SOM_ENDTRY
  577.     
  578.     return result ;
  579. }
  580.  
  581. SOM_Scope ODBoolean  SOMLINK ODBindingGetUserStringForCategory(ODBinding *somSelf, Environment *ev,
  582.         ODCategory category,
  583.         ODName* name)
  584. {
  585.     ODBindingData *somThis = ODBindingGetData(somSelf);
  586.     ODBindingMethodDebug("ODBinding","ODBindingGetUserStringForCategory");
  587.  
  588.     ODBoolean    result  = kODFalse ;
  589.     ODName*        userString = kODNULL;
  590.  
  591.     SOM_TRY
  592.     
  593.         // look it up in the spaceName namespace
  594.     ODValueNameSpace* userStringNameSpace = 
  595.         (ODValueNameSpace*)_fNmSpcMgr->HasNameSpace( ev, kODCategoryUserString );
  596.  
  597.     if (userStringNameSpace)
  598.         result = ValueNameSpaceGetODName(userStringNameSpace, ev, category, &userString );
  599.     
  600.     if (userString)
  601.         *name = *userString;
  602.     else
  603.         InitIText(name);
  604.  
  605.     SOM_CATCH_ALL
  606.     SOM_ENDTRY
  607.     
  608.     return result ;
  609. }
  610.  
  611. SOM_Scope ODBoolean  SOMLINK ODBindingEditorSupportsKind(ODBinding *somSelf, Environment *ev,
  612.         ODEditor editor,
  613.         ODKind kind)
  614. {
  615.     ODBindingData *somThis = ODBindingGetData(somSelf);
  616.     ODBindingMethodDebug("ODBinding","ODBindingEditorSupportsKind");
  617.  
  618.     ODBoolean    result = kODFalse;
  619.  
  620.     SOM_TRY
  621.     
  622.         // get the editorkinds namespace
  623.     ODObjectNameSpace* editorkindsNameSpace = 
  624.         (ODObjectNameSpace*)_fNmSpcMgr->HasNameSpace( ev, kODEditorKinds );
  625.     
  626.     ODTypeList*    kindsList = kODNULL;
  627.  
  628.     if (editorkindsNameSpace)
  629.     {
  630.             // Lookup the kinds list by editor class ID
  631.         if (!editorkindsNameSpace->GetEntry( ev, (ODISOStr)editor, 
  632.                                     (ODObject**)&kindsList ))
  633.             kindsList = (ODTypeList*)kODNULL;
  634.     }
  635.  
  636.     result    = (kindsList && kindsList->Contains(ev, kind));
  637.     
  638.     SOM_CATCH_ALL
  639.     SOM_ENDTRY
  640.     
  641.     return result;
  642. }
  643.  
  644. SOM_Scope void  SOMLINK ODBindingGetAllEditors(ODBinding *somSelf, Environment *ev,
  645.         ODTypeList* editorList)
  646. {
  647.     ODBindingData *somThis = ODBindingGetData(somSelf);
  648.     ODBindingMethodDebug("ODBinding","ODBindingGetAllEditors");
  649.  
  650.     ODObjectIterator* iter = kODNULL; ODVolatile(iter);
  651.     
  652.     SOM_TRY
  653.     
  654.         // get the editorkinds namespace
  655.     ODObjectNameSpace* editorkindsNameSpace = 
  656.         (ODObjectNameSpace*)_fNmSpcMgr->HasNameSpace( ev, kODEditorKinds );
  657.     
  658.     if (editorkindsNameSpace)
  659.     {
  660.     
  661.         ODTypeList* kindsList     = kODNULL;
  662.         ODEditor     editor        = kODNULL;
  663.         ODULong        len         = 0;
  664.  
  665.         //    iterate through editorKinds namespace
  666.         iter = editorkindsNameSpace->CreateIterator(ev) ;
  667.         for (iter->First(ev, (ODISOStr*)&editor, (ODObject**)&kindsList, &len);
  668.                 iter->IsNotComplete(ev);
  669.                 iter->Next(ev, (ODISOStr*)&editor, (ODObject**)&kindsList, &len))
  670.         {
  671.             editorList->AddLast(ev, editor);
  672.         }
  673.         
  674.         ODDeleteObject( iter );
  675.     }
  676.     
  677.     SOM_CATCH_ALL
  678.         ODDeleteObject( iter );
  679.     SOM_ENDTRY
  680. }
  681.  
  682. SOM_Scope ODOSType  SOMLINK ODBindingGetODOSTypeForKind(ODBinding *somSelf, Environment *ev,
  683.         ODType kind)
  684. {
  685.     ODBindingData *somThis = ODBindingGetData(somSelf);
  686.     ODBindingMethodDebug("ODBinding","ODBindingODGetODOSTypeForKind");
  687.  
  688.     ODOSType theOSType = kODNULL;
  689.     
  690.     SOM_TRY
  691.     
  692.         // look it up in the editorkinds namespace
  693.     ODValueNameSpace* kindOldMacOSTypeNameSpace = 
  694.         (ODValueNameSpace*)_fNmSpcMgr->HasNameSpace( ev, 
  695.                                                    kODKindOldMacOSType );
  696.     
  697.     if (kindOldMacOSTypeNameSpace)
  698.     {
  699.         ODOSType*     typePtr        = kODNULL;
  700.         ODULong        valueLen     = 0;
  701.         if (ValueNameSpaceGetEntry( 
  702.                                 kindOldMacOSTypeNameSpace, ev, kind, 
  703.                                 (ODPtr*) &typePtr, &valueLen ))
  704.         {
  705.             theOSType = *typePtr;
  706.             ODDeleteObject( typePtr );
  707.         }
  708.     }
  709.     
  710.     SOM_CATCH_ALL
  711.     SOM_ENDTRY
  712.     
  713.     return theOSType;
  714. }
  715.  
  716. SOM_Scope void  SOMLINK ODBindingsomUninit(ODBinding *somSelf)
  717. {
  718.     ODBindingData *somThis = ODBindingGetData(somSelf);
  719.     ODBindingMethodDebug("ODBinding","ODBindingsomUninit");
  720.  
  721.     ODDeleteObject( _fBinding );
  722.     
  723.     ODBinding_parent_ODObject_somUninit(somSelf);
  724. }
  725.  
  726. SOM_Scope ODSize  SOMLINK ODBindingPurge(ODBinding *somSelf, Environment *ev,
  727.         ODSize size)
  728. {
  729.     ODBindingData *somThis = ODBindingGetData(somSelf);
  730.     ODBindingMethodDebug("ODBinding","ODBindingPurge");
  731.  
  732.     ODSize returnVal = 0; ODVolatile( returnVal );
  733.  
  734.     SOM_TRY
  735.  
  736.         returnVal = _fBinding->Purge(size);
  737.  
  738.     SOM_CATCH_ALL
  739.         WARN("Error %ld trying to purge in ODBindingPurge",ErrorCode());
  740.         SetErrorCode(kODNoError);        // dh - Eat the exception; Purge should not 
  741.                                         // propagate it because clients function
  742.                                         // fine whether memory was purged or not.
  743.     SOM_ENDTRY
  744.  
  745.     return(returnVal);
  746. }
  747.